<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>kq.1.06Form操纵</title>
<meta name="viewport" content="initial-scale=1, width=device-width, maximum-scale=1, user-scalable=no">
<link rel="stylesheet" type="text/css" href="https://res.kuoqps.com/kuoqi-ui/web.dev.css">
<script src="../kq.1.06.dev.js"></script>
</head>

<body>
<div>
<form id="form" class="form" method="post" onSubmit="return false;">
	<input name="test" />
    <input name="arr[]" />
    <input name="arr[]" />
    <input type="checkbox" name="one" value="1" />
    <input type="checkbox" name="two" value="2" />
    <input type="checkbox" name="three" value="3" />
    <input type="radio" name="four" value="1" />
    <input type="radio" name="four" value="2" />
    <input type="radio" name="four" value="3" />
    <input data-type="require" name="require" placeholder="必填字段" />
	<button type="submit">表单提交</button>
</form>
<form id="moreFile" action="" method="">
	<input type="file" name="filename" multiple />
	<button type="submit">多文件上传</button>
</form>
<form id="formSec" action="" method="">
	<input type="file" name="filename" />
	<button type="submit">分片上传</button>
</form>
<form id="formProgress" action="" method="">
	<input type="file" name="filename" />
	<button type="submit">上传进度显示</button>
</form>
<button id="ajaxGet">ajaxGet传参</button>
<hr />
<div id="virtualFormDiv"></div>
<form class="mgt-15" id="virtualForm" action="" method="" onSubmit="return false;" enctype="multipart/form-data">
	<button type="submit" class="btn">点我生成表单，请使用form对象进行调试</button>
</form>


<script>
$Q.config('DEBUG',true);
var form = null;
//提交创建的虚拟表单
$Q('#virtualForm').submit(function(){
	try{
		var url = '';
		form = new $Q.form(this);
		form.append('姓名','测试一下');
		form.append('工作','表单测试工程师');
		form.setMethod('post');
		form.setEnctype('application/x-www-form-urlencoded"');
		form.setAction('https://api.kuoqps.cn/Index/formDemo');
		form.setTarget('target="new"');
		//form.submit('https://api.kuoqps.cn/Index/formDemo');//form表单提交
		form.print();
		console.log(form);
	}catch(err){
		console.log(err);
	}
	return false;	
});
</script>

</div>
</body>
<script>



$Q("#formSec").submit(function(){
	try{
		var files = $Q('[name="filename"]').files();
		var file = files.item(0);
		file.secSize = 1024 * 512 * 10;
		file.secCheck = function(rs){
			if(rs.status==1){
				return true;
			}else{
				return false;
			}
		}
		file.upload('http://cpanel.kuoqps.com/api/music/upload'
			,function(rs){console.log(rs);}
			,function(){
				$Q.msg('上传失败');	
			}
		);
	}catch(err){console.log(err);}
	return ;	
});

$Q("#form").submit(function(){
	$Q('#form').ajaxSubmit({
		success:function(rs){console.log(rs);},
		error:function(){console.log();}	
	});
	return ;		
});
$Q("#formProgress").submit(function(){
	try{
		var files = $Q('[name="filename"]').files();
		var file = files.item(0);
		file.uploadSepeed = function(rs){
			console.log(rs);	
		}
		file.upload('http://cpanel.kuoqps.com/api/music/upload'
			,function(rs){console.log(rs);}
			,function(){
				$Q.msg('上传失败');	
			}
		);
	}catch(err){
		console.log(err);	
	}
	return ;		
});

$Q('#ajaxGet').click(function(){
	$Q.ajax({
		url:'https://dev.m.chuanjiafeng.net/citymatch-album/config?a=b',
		type:'get',
		data:{
			a:'a',b:'cd'	
		},
		success:function(){},
		error:function(){}
	});	
});

var debug = null;
</script>
</html>
